﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DaInterFace;
using DaInterFace.Mobile;

namespace J01
{
    //所有销售订单
    public class A01 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            //Dictionary<string, MoneyClientOrder> ht = new Dictionary<string, MoneyClientOrder>();
            List<MoneyClientOrder> ht = new List<MoneyClientOrder>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[3];
            sps[0] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;
            sps[1] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[1].Value = fp.StartTime;
            sps[2] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.EndTime;

            string strSQL = "select A.FID 销售账户FID,A.FBillNo 销售账户编号,D.FName 客户名称,A.FDecimal 付款总计,A.FDecimal1 消费总计,A.FDecimal5 当前余额,A.FDate 下单日期,A.FComboBox 密码方式,E.FName 结算方式,A.FBillNo_SRC 档案编号 from KEW_SalesAccount A ";
            strSQL = strSQL + "left join KEW_SalesGuests B on B.FID=A.FID_SRC ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase1 ";
            strSQL = strSQL + "where B.FBillNo=@FBillNo and (A.FDate>=@StartTime or @StartTime= '') and (A.FDate<=@EndTime or @EndTime= '') order by A.FDecimal2 asc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        MoneyClientOrder orderInfor = new MoneyClientOrder();

                        orderInfor.FID = dr[0].ToString();
                        orderInfor.FBillNo = dr[1].ToString();
                        orderInfor.ClientName = dr[2].ToString();
                        orderInfor.PaymentTotal = Math.Round(Common.CDec(dr[3].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.ConsumeTotal = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.CurrentBalance = Math.Round(Common.CDec(dr[5].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.BuildTime = dr[6].ToString();
                        if (dr[7].ToString().Equals("0"))
                        {
                            orderInfor.PassWordWay = "无密码";
                        }
                        else if (dr[7].ToString().Equals("1"))
                        {
                            orderInfor.PassWordWay = "固态密码";
                        }
                        else if (dr[7].ToString().Equals("2"))
                        {
                            orderInfor.PassWordWay = "动态密码";
                        }

                        orderInfor.CaculateWay = dr[8].ToString();
                        orderInfor.GuestFBillNo = dr[9].ToString();
                        orderInfor.TotalPages = nTotalPages;

                        ht.Add(orderInfor);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;

                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //销售订单详情
    public class A02 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            // Dictionary<string, MoneyClientOrder> ht = new Dictionary<string, MoneyClientOrder>();
            List<MoneyClientOrder> ht = new List<MoneyClientOrder>();
            MoneyClientOrder orderInfor = new MoneyClientOrder();
            string strNewFID = "";

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            //2624 1
            string strSQL = "select A.FID 销售账户FID,A.FBillNo 销售账户编号,D.FName 客户名称,A.FDecimal 付款总计,A.FDecimal1 消费总计,A.FDecimal5 当前余额,A.FDate 下单日期,A.FComboBox 密码方式,E.FName 结算方式,A.FBillNo_SRC 档案编号,C.FEntryID 销售账户单据体FID,F.FName 产品,C.FText 执行政策,C.FDecimal3 含税单价 from KEW_SalesAccount A ";
            strSQL = strSQL + "left join KEW_SalesGuests B on B.FID=A.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesAccountEntry C on C.FID=A.FID ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products F on F.FID=C.FBase2 ";
            strSQL = strSQL + "where A.FID=@FID order by A.FDate desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ProductInfor productInfor = new ProductInfor();

                    if (!strNewFID.Equals(dr[0].ToString()))
                    {
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.FBillNo = dr[1].ToString();
                        orderInfor.ClientName = dr[2].ToString();
                        orderInfor.PaymentTotal = Math.Round(Common.CDec(dr[3].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.ConsumeTotal = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.CurrentBalance = Math.Round(Common.CDec(dr[5].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.BuildTime = dr[6].ToString();
                        if (dr[7].ToString().Equals("0"))
                        {
                            orderInfor.PassWordWay = "无密码";
                        }
                        else if (dr[7].ToString().Equals("1"))
                        {
                            orderInfor.PassWordWay = "固态密码";
                        }
                        else if (dr[7].ToString().Equals("2"))
                        {
                            orderInfor.PassWordWay = "动态密码";
                        }

                        orderInfor.CaculateWay = dr[8].ToString();
                        orderInfor.GuestFBillNo = dr[9].ToString();
                        strNewFID = orderInfor.FID;
                    }

                    productInfor.FID = dr[10].ToString();
                    productInfor.ProductName = dr[11].ToString();
                    productInfor.PolicyImplementation = dr[12].ToString();
                    productInfor.TaxPrice = Math.Round(Common.CDec(dr[13].ToString()), Common.PricePrecision).ToString();

                    orderInfor.listCarInfor.Add(productInfor);
                }
            }

            ht.Add(orderInfor);
            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }

    }

    //所有销售车辆
    public class A03 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            string strQuery = "";
            // Dictionary<string, SalesCarInfor> ht = new Dictionary<string, SalesCarInfor>();
            List<SalesCarInfor> ht = new List<SalesCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[5];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;
            sps[1] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[1].Value = user.UserName;
            sps[2] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.StartTime;
            sps[3] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[3].Value = fp.EndTime;
            sps[4] = new SqlParameter("@CalStatus", SqlDbType.Int);
            sps[4].Value = fp.CalStatus;

            string strSQL = "select distinct(A.FID) 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FDecimal 进厂重量,A.FDecimal17 出厂重量,A.FDecimal3 实际净重,A.FDecimal3 出库数量,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FTime1 进厂时间,A.FTime2 出厂时间,A.FText8 磁卡,A.FText12 发货授权编号,B.FName 客户,C.FName 产品,A.FText1 开票人员,A.FText2 进厂司磅,A.FText3 出厂司磅,A.FDecimal19 盈亏,A.FText9 签发人员,D.FName 销售车辆,A.FComboBox3 生产线, A.FCheckBox4 作废标志 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SalesAccount F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests G on G.FID=F.FID_SRC ";
            strSQL = strSQL + "where (F.FID=@FID or @FID='') and G.FBillNo=@FBillNo and (A.FTime2>=@StartTime or @StartTime='') and (A.FTime2<=@EndTime or @EndTime='')and ((A.FCheckBox4=case when  (@CalStatus= 4 and @CalStatus<> -100)then 1 else 0 end) or(A.FCheckBox4!=case when @CalStatus= -100 then '' end)) and ((A.FComboBox=case when (@CalStatus<> -100 and @CalStatus<>4) then @CalStatus end) or (A.FComboBox!=case when (@CalStatus= -100 or @CalStatus=4) then '' end)) order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesCarInfor orderInfor = new SalesCarInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.WeighNumber = dr[1].ToString();
                        orderInfor.CarNumber = dr[2].ToString();
                        orderInfor.PreviousPlan = Math.Round(Common.CDec(dr[3].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.InWeight = Math.Round(Common.CDec(dr[4].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutWeight = Math.Round(Common.CDec(dr[5].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.FactNetWeight = Math.Round(Common.CDec(dr[6].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutStorage = Math.Round(Common.CDec(dr[7].ToString()), Common.QtyPrecision).ToString();

                        strQuery = dr[8].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighStatues = "开票";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighStatues = "已开票";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighStatues = "已进厂计量";
                        }
                        else if (Common.CInt(strQuery) == 3)
                        {
                            orderInfor.WeighStatues = "计量完成";
                        }
                        else if (Common.CInt(strQuery) == -1)
                        {
                            orderInfor.WeighStatues = "已发货授权";
                        }

                        strQuery = dr[24].ToString().Trim();
                        if (Common.CBool(strQuery))
                        {
                            orderInfor.WeighStatues = "已作废";
                        }

                        strQuery = dr[9].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighType = "正常过磅";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighType = "退货";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighType = "空车出厂";
                        }

                        orderInfor.TicketTime = dr[10].ToString();
                        orderInfor.InTime = dr[11].ToString();
                        orderInfor.OutTime = dr[12].ToString();
                        orderInfor.CardNum = dr[13].ToString();
                        orderInfor.OrderNumber = dr[14].ToString();
                        orderInfor.ClientName = dr[15].ToString();
                        orderInfor.ProductName = dr[16].ToString();
                        orderInfor.BillingMan = dr[17].ToString();
                        orderInfor.InSiBang = dr[18].ToString();
                        orderInfor.OutSiBang = dr[19].ToString();
                        orderInfor.ProfitAndLoss = Math.Round(Common.CDec(dr[20].ToString()), Common.PricePrecision).ToString();
                        orderInfor.SignMan = dr[21].ToString();
                        orderInfor.SalesCar = dr[22].ToString();
                        orderInfor.ProduceNumber = dr[23].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //所有发货授权车辆
    public class A04 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            // Dictionary<string, AuthCarInfor> ht = new Dictionary<string, AuthCarInfor>();
            List<AuthCarInfor> ht = new List<AuthCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            string strSQL = "select distinct(A.FID) 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FText14 发货授权编号,B.FName 客户,C.FName 产品,C.FID 产品FID,C.FCheckBox 是否袋装,F.FDecimal2 剩余金额 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_ProductsEntry C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SalesAccount F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "where F.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        AuthCarInfor authCar = new AuthCarInfor();

                        authCar.FID = dr["车辆FID"].ToString();
                        authCar.OrderFID = fp.OrderFID;
                        authCar.WeighNumber = dr["过磅编号"].ToString();
                        authCar.PreviousPlan = Math.Round(Common.CDec(dr["计划预装"].ToString()), Common.QtyPrecision).ToString();
                        authCar.AuthNumber = dr["发货授权编号"].ToString();
                        authCar.CarNumber = dr["车牌号码"].ToString();
                        authCar.ProductName = dr["产品"].ToString();
                        authCar.ProductFID = dr["产品FID"].ToString();
                        authCar.IsBag = dr["是否袋装"].ToString();
                        // authCar.Price = Math.Round(Double.Parse(dr["产品单价"].ToString()), 0).ToString("0.00");
                        authCar.TotalPages = nTotalPages;
                        ht.Add(authCar);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //生成发货授权单（单一订单）
    public class A05 : IMobileChild
    {
        ///// <summary>
        ///// 生成4位数字随机数。
        ///// </summary>
        ///// <returns>生成的随机数</returns>
        //private string random_6()
        //{
        //    Random rad = new Random();//实例化随机数产生器rad；
        //    string strRandom = "";
        //    strRandom = Convert.ToString(rad.Next(111000, 999999));

        //    return strRandom;
        //}
        private int GetRandom(IMobile handler,String accountid)
        {
            Random rd = new Random();
            int random = rd.Next(1000000, 10000000);

            int nResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@Random", SqlDbType.Int);
            sps[0].Value = random;

            String AuthCar = accountid + random.ToString();
            string strSql = " select * from KEW_SalesInfo where FText14='" + AuthCar.Trim() + "' and FComboBox = '-1' ";

            Recordset rs = handler.Data.ExeProcedure(accountid, strSql, sps);
            nResult = rs.Data.Tables[0].Rows.Count;
          
            //查数据
            if (nResult>0)
            {
                GetRandom(handler,accountid);
            }
            return random;

        }

        #region 获取当天某订单下发货授权车数
        /// <summary>
        /// 获取当天某订单下发货授权车数
        /// </summary>
        /// <param name="strFID">销售订单的FID</param>
        /// <param name="strConnection">连接字符串</param>
        /// <returns></returns>
        private int GetAuthCarCountNow(string strFID, IMobile handler, ClientUser user)
        {
            int nResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = strFID;

            string strSQL = "select * from KEW_SalesInfo A ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry B on B.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty C on C.FID=B.FID_SRC ";
            strSQL = strSQL + "where C.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' and A.FTime>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and A.FTime<='" + DateTime.Now.ToString() + "'";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);
            nResult = rs.Data.Tables[0].Rows.Count;

            return nResult;
        }
        #endregion

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nTimes = -1;

            FunctionParameter fp = new FunctionParameter();
            AuthCarInfor AuthCar = (AuthCarInfor)handler.Json.JsonToClass(fp.SalesAuthCarInfo, typeof(AuthCarInfor)); ;

            nTimes = GetAuthCarCountNow(fp.OrderFID, handler, user);
            if (5 < nTimes)
            {
                return "OverLimit";
            }

            SqlParameter[] sps = new SqlParameter[7];
            sps[0] = new SqlParameter("@SaleOrderQtyFID", SqlDbType.NChar, 50);
            sps[0].Value = AuthCar.OrderFID;
            sps[1] = new SqlParameter("@CarNo", SqlDbType.NChar, 50);
            sps[1].Value = AuthCar.CarNumber;
            sps[2] = new SqlParameter("@PreQTY", SqlDbType.Decimal);
            sps[2].Value = AuthCar.PreviousPlan;
            sps[3] = new SqlParameter("@Stamp", SqlDbType.NChar, 50);
            sps[3].Value = AuthCar.TakePass;
            sps[4] = new SqlParameter("@AuthCar", SqlDbType.NVarChar, 50);
            //sps[4].Value = user.AccountID + random_6();
            sps[4].Value = user.AccountID + GetRandom(handler,user.AccountID);
            sps[5] = new SqlParameter("@ItemID", SqlDbType.NChar, 50);
            sps[5].Value = AuthCar.ProductFID;
            sps[6] = new SqlParameter("@OrderPrice", SqlDbType.Decimal);
            sps[6].Value = AuthCar.Price;

            string strSQL = "Exec KEW_SALES_SAVE4 @SaleOrderQtyFID, @CarNo, @PreQTY, @Stamp, @AuthCar, @ItemID, @OrderPrice";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            strResult = rs.Data.Tables[0].Rows[0][0].ToString();

            return strResult;
        }
    }

    //作废发货授权单
    public class A06 : IMobileChild
    {

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.AuthCarFID;

            string strSQL = "Exec KEW_SALESAUTH_CANCEL @FID";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            strResult = rs.Data.Tables[0].Rows[0][0].ToString();

            return strResult;
        }

    }

    //所有产品实际价格
    public class A07 : IMobileChild
    {
        #region 获取实际价格
        /// <summary>
        /// 获取实际价格
        /// </summary>
        /// <param name="strOrderFID">订单FID</param>
        /// <param name="strFID">产品FID</param>
        /// <param name="strConnection">连接字符串</param>
        /// <returns></returns>
        private string GetFactualPrice(string strOrderFID, string strFID, IMobile handler, ClientUser user)
        {
            try
            {
                SqlParameter[] sps = new SqlParameter[2];
                sps[0] = new SqlParameter("@OrderFID", SqlDbType.NChar, 50);
                sps[0].Value = strOrderFID;
                sps[1] = new SqlParameter("@FID", SqlDbType.NChar, 50);
                sps[1].Value = strFID;

                string strSQL = "select FDecimal3 from KEW_SalesAccountEntry where FID=@OrderFID and FBase2=@FID";
                Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

                if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
                {
                    SqlParameter[] sps1 = new SqlParameter[1];
                    sps1[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
                    sps1[0].Value = strFID;
                    strSQL = "select FDecimal2 from KEW_ProductsEntry where FID=@FID";

                    rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps1);

                    if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
                    {
                        return "";
                    }
                }

                return rs.Data.Tables[0].Rows[0][0].ToString();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

        }
        #endregion

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            //Dictionary<string, ProductInfor> ht = new Dictionary<string, ProductInfor>();
            List<ProductInfor> ht = new List<ProductInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            //string strSQL = "select FID,FName,FDecimal2 from KEW_ProductsEntry order by FID desc";
            //string strSQL = "select a.FID, a.FName, a.FDecimal2, a.FCheckBox, b.FDecimal from KEW_ProductsEntry a left join KEW_ProductsBagRuleEntry b on a.Fbase1 = b.FID  order by a.FID desc";
            string strSQL = "select a.FBase2, b.FName,a.FDecimal3, b.FCheckBox, c.FDecimal  from KEW_SalesAccountEntry a left join KEW_ProductsEntry b on a.FBase2 = b.FID left join KEW_ProductsBagRuleEntry c on b.FBase1 = c.FID where a.fid = @FID order by b.FID  desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {

                    ProductInfor orderInfor = new ProductInfor();
                    orderInfor.FID = dr[0].ToString();
                    orderInfor.ProductName = dr[1].ToString();
                    orderInfor.IsBag = dr[3].ToString();
                    orderInfor.BagWeight = dr[4].ToString();
                    orderInfor.TaxPrice = Math.Round(Common.CDec(dr[2].ToString()), Common.PricePrecision).ToString();
                    //strResult = GetFactualPrice(fp.OrderFID, orderInfor.FID, handler, user);
                    //if (strResult.Equals(""))
                    //{
                    //   orderInfor.TaxPrice = Math.Round(Common.CDec(dr[2].ToString()), Common.PricePrecision).ToString();
                    //}
                    //else
                    //{
                    //    orderInfor.TaxPrice = Math.Round(Common.CDec(strResult), Common.PricePrecision).ToString();
                    //}
                    ht.Add(orderInfor);
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //订单下某一产品的实际价格
    public class A08 : IMobileChild
    {
        #region 获取实际价格
        /// <summary>
        /// 获取实际价格
        /// </summary>
        /// <param name="strOrderFID">订单FID</param>
        /// <param name="strFID">产品FID</param>
        /// <param name="strConnection">连接字符串</param>
        /// <returns></returns>
        private string GetFactualPrice(string strOrderFID, string strFID, IMobile handler, ClientUser user)
        {
            try
            {
                SqlParameter[] sps = new SqlParameter[2];
                sps[0] = new SqlParameter("@OrderFID", SqlDbType.NChar, 50);
                sps[0].Value = strOrderFID;
                sps[1] = new SqlParameter("@FID", SqlDbType.NChar, 50);
                sps[1].Value = strFID;

                string strSQL = "select FDecimal3 from KEW_SalesAccountEntry where FID=@OrderFID and FBase2=@FID";
                Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

                if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
                {
                    SqlParameter[] sps1 = new SqlParameter[1];
                    sps1[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
                    sps1[0].Value = strFID;
                    strSQL = "select FDecimal2 from KEW_ProductsEntry where FID=@FID";

                    rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps1);

                    if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
                    {
                        return "";
                    }
                }

                return rs.Data.Tables[0].Rows[0][0].ToString();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

        }
        #endregion

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            FunctionParameter fp = new FunctionParameter();

            var varFP = (object)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));
            fp = (FunctionParameter)varFP;

            strResult = GetFactualPrice(fp.OrderFID, fp.ProductFID, handler, user);
            return strResult;
        }
    }

    //补录发货授权单（选多个订单）
    public class A09 : IMobileChild
    {
        /// <summary>
        /// 生成4位数字随机数。
        /// </summary>
        /// <returns>生成的随机数</returns>
        //private string random_6()
        //{
        //    Random rad = new Random();//实例化随机数产生器rad；
        //    string strRandom = "";
        //    strRandom = Convert.ToString(rad.Next(111000, 999999));

        //    return strRandom;
        //}
        private int GetRandom(IMobile handler, String accountid)
        {
            Random rd = new Random();
            int random = rd.Next(1000000, 10000000);

            int nResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@Random", SqlDbType.Int);
            sps[0].Value = random;

            String AuthCar = accountid + random.ToString();
            string strSql = " select * from KEW_SalesInfo where FText14='" + AuthCar.Trim() + "' and FComboBox = '-1' ";

            Recordset rs = handler.Data.ExeProcedure(accountid, strSql, sps);
            nResult = rs.Data.Tables[0].Rows.Count;

            //查数据
            if (nResult > 0)
            {
                GetRandom(handler, accountid);
            }
            return random;

        }

        public List<OrderPro> Sort(List<OrderPro> listorderPro)
        {
            OrderPro temp = new OrderPro();
            for (int i = 0; i < listorderPro.Count; i++)
            {
                for (int j = i; j < listorderPro.Count; j++)
                {
                    if (Common.CDec(listorderPro[i].CurrentBalance) >= Common.CDec(listorderPro[j].CurrentBalance))
                    {
                        temp = listorderPro[i];
                        listorderPro[i] = listorderPro[j];
                        listorderPro[j] = temp;
                    }
                }
            }

            return listorderPro;
        }

        #region 获取当天某订单下发货授权车数
        /// <summary>
        /// 获取当天某订单下发货授权车数
        /// </summary>
        /// <param name="strFID">销售订单的FID</param>
        /// <param name="strConnection">连接字符串</param>
        /// <returns></returns>
        private int GetAuthCarCountNow(string strFID, IMobile handler, ClientUser user)
        {
            int nResult = 0;
            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = strFID;

            string strSQL = "select * from KEW_SalesInfo A ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry B on B.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SaleOrderQty C on C.FID=B.FID_SRC ";
            strSQL = strSQL + "where C.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' and A.FTime>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and A.FTime<='" + DateTime.Now.ToString() + "'";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);
            nResult = rs.Data.Tables[0].Rows.Count;

            return nResult;
        }
        #endregion

        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            FunctionParameter fp = new FunctionParameter();
            List<OrderPro> op = new List<OrderPro>();
            AuthCarInfor sc = new AuthCarInfor();
            List<AuthResult> ht = new List<AuthResult>();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));
            sc = (AuthCarInfor)handler.Json.JsonToClass(fp.SalesAuthCarInfo, typeof(AuthCarInfor));

            if (!sc.listOrderPro.Equals("[]"))
            {
                op = (List<OrderPro>)handler.Json.JsonToClass(sc.listOrderPro, typeof(List<OrderPro>));
                op = Sort(op);
            }

            SqlParameter[] sps = new SqlParameter[7 + op.Count * 3];
            sps[0] = new SqlParameter("@SaleOrderQtyFID", SqlDbType.NChar, 50);
            sps[0].Value = sc.OrderFID;
            sps[1] = new SqlParameter("@CarNo", SqlDbType.NChar, 50);
            sps[1].Value = sc.CarNumber;
            sps[2] = new SqlParameter("@PreQTY", SqlDbType.NChar, 50);
            sps[2].Value = sc.PreviousPlan;
            sps[3] = new SqlParameter("@Stamp", SqlDbType.NChar, 50);
            sps[3].Value = sc.TakePass;
            sps[4] = new SqlParameter("@AuthCar", SqlDbType.NVarChar, 50);
            //sps[4].Value = user.AccountID + random_6();
            sps[4].Value = user.AccountID + GetRandom(handler, user.AccountID);
            sps[5] = new SqlParameter("@ItemID", SqlDbType.NChar, 50);
            sps[5].Value = sc.ProductFID;
            sps[6] = new SqlParameter("@ProductPrice", SqlDbType.NChar, 50);
            sps[6].Value = sc.Price;

            for (int i = 0; i < op.Count; i++)
            {
                sps[7 + 3 * i] = new SqlParameter("@OrderFID" + i.ToString(), SqlDbType.NChar, 50);
                sps[7 + 3 * i].Value = op[i].OrderFID;
                sps[8 + 3 * i] = new SqlParameter("@ProductPrice" + i.ToString(), SqlDbType.NChar, 50);
                sps[8 + 3 * i].Value = op[i].ProductPrice;
                sps[9 + 3 * i] = new SqlParameter("@TakePass" + i.ToString(), SqlDbType.NChar, 50);
                sps[9 + 3 * i].Value = op[i].TakePass;
            }

            string strSQL = "SET NOCOUNT ON ";
            strSQL = strSQL + "DECLARE @FID INT ";
            strSQL = strSQL + "DECLARE @BillNo NVARCHAR(50) ";
            strSQL = strSQL + "DECLARE @Now DATETIME ";
            strSQL = strSQL + "DECLARE @BalTotalMoney DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @BalCurrentMoney DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @BalConsumeMoney DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @OrderPrice DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @OrderNo NVARCHAR(50) ";
            strSQL = strSQL + "DECLARE @OrderID INT ";
            strSQL = strSQL + "DECLARE @OrderTypeID INT ";
            strSQL = strSQL + "DECLARE @OrderPayType INT ";
            strSQL = strSQL + "DECLARE @GustID INT ";
            strSQL = strSQL + "DECLARE @UnitID INT ";
            strSQL = strSQL + "DECLARE @ReplenisFirstPreQTY DECIMAL(23,10) ";
            strSQL = strSQL + "DECLARE @ErrorCount AS INT ";
            strSQL = strSQL + "SET @ErrorCount=0 ";
            strSQL = strSQL + "IF (SELECT COUNT(1) FROM KEW_SalesInfo WHERE FText5=@Stamp)>0 BEGIN SELECT 'FALSE','不能重复插入！' ";
            strSQL = strSQL + "RETURN ";
            strSQL = strSQL + "END ";
            strSQL = strSQL + "EXEC KEW_GET_BillNo 236900103,1,@BillNo OUTPUT ";
            strSQL = strSQL + "IF @BillNo='' BEGIN ";
            strSQL = strSQL + "SELECT 'FALSE','新增销售过磅信息时获取单据编号出错！' ";
            strSQL = strSQL + "RETURN END ";
            strSQL = strSQL + "EXEC GetICMaxNum 'KEW_SalesInfo',@FID OUTPUT ";
            //strSQL = strSQL + "set @AuthCar=left(@AuthCar,1)+ @BillNo+right(@AuthCar,6) ";
            strSQL = strSQL + "SET @Now=GETDATE() ";
            strSQL = strSQL + "select @UnitID=FBase2 from KEW_ProductsEntry where FID=@ItemID ";
            strSQL = strSQL + "SELECT @OrderPayType=FBase1, @BalCurrentMoney=FDecimal5,@BalTotalMoney=FDecimal,@BalConsumeMoney=FDecimal1,@GustID=FBase,@OrderNo=FBillNo,@OrderID=FID,@OrderTypeID=FClassTypeID ";
            strSQL = strSQL + "FROM KEW_SalesAccount WHERE FID= @SaleOrderQtyFID ";
            strSQL = strSQL + "BEGIN TRAN ";
            //strSQL = strSQL + "INSERT INTO KEW_SalesInfo ([FID],[FClassTypeID],[FBillNo],[FAmount],[FAmount1],[FAmount2],[FComboBox],[FText],[FDecimal] ";
            strSQL = strSQL + "INSERT INTO KEW_SalesInfo ([FID],[FClassTypeID],[FBillNo],[FComboBox],[FText],[FDecimal] ";
            strSQL = strSQL + ",[FDecimal1],[FDecimal2],[FDecimal3],[FDecimal4],[FTime],[FTime1],[FTime2],[FText1],[FText2],[FText3],[FBase],[FNOTE] ";
            strSQL = strSQL + ",[FCheckBox],[FBase1],[FBase2],[FText4],[FText8],[FText5],[FNOTE2],[FCheckBox4],[FComboBox2],[FText14],[FBase6],[FBase5]) VALUES ";
            //strSQL = strSQL + "(@FID,236900103,@BillNo,0.00,0.00,0.00,'-1',@CarNo,0.00 ";
            strSQL = strSQL + "(@FID,236900103,@BillNo,'-1',@CarNo,0.00 ";
            strSQL = strSQL + ",0,0,0,@PreQty,@Now,Null,Null,'','','',@ItemID,'' ";
            strSQL = strSQL + ",0,@GustID,@UnitID,'','',@Stamp,'',0,'0',@AuthCar,@OrderPayType,@UnitID) ";
            strSQL = strSQL + "SET @ErrorCount=@ErrorCount+@@ERROR ";

            if (op.Count==0)
            {
                strSQL = strSQL + "set @OrderPrice=@ProductPrice ";
                strSQL = strSQL + "if @BalCurrentMoney/@OrderPrice>=@PreQTY begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=@PreQTY set @PreQTY=0 end ";
                strSQL = strSQL + "else begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=round(@BalCurrentMoney/@OrderPrice,2,1) ";
                strSQL = strSQL + "set @PreQTY=@PreQTY-@ReplenisFirstPreQTY ";
                strSQL = strSQL + "end ";
                strSQL = strSQL + "INSERT INTO KEW_SalesInfoEntry ([FID],[FIndex],[FBillNo_SRC],[FClassID_SRC],[FComboBox1],[FDecimal11],[FDecimal5] ";
                strSQL = strSQL + ",[FDecimal6],[FDecimal7],[FDecimal8],[FDecimal9],[FDecimal10],[FID_SRC],[FEntryID_SRC],[FCheckBox2],[FBase4] ";
                strSQL = strSQL + ",[FText6],[FText7],[FInteger]) VALUES (@FID,1,@OrderNo,@OrderTypeID,'',0,0 ";
                strSQL = strSQL + ",@BalCurrentMoney,@OrderPrice,0,@ReplenisFirstPreQTY,ROUND(@ReplenisFirstPreQTY*@OrderPrice,2),@OrderID,0,0,@GustID,@Stamp,'',0) ";
                strSQL = strSQL + "SET @ErrorCount=@ErrorCount+@@ERROR ";
            }

            for (int i = 0; i < op.Count; i++)
            {
                strSQL = strSQL + "SELECT @BalCurrentMoney=FDecimal2,@BalTotalMoney=FDecimal,@BalConsumeMoney=FDecimal1,@GustID=FBase,@OrderNo=FBillNo,@OrderID=FID,@OrderTypeID=FClassTypeID ";
                strSQL = strSQL + "FROM KEW_SalesAccount WHERE FID=@OrderFID" + i.ToString() + " ";
                strSQL = strSQL + "set @OrderPrice=@ProductPrice" + i.ToString() + " ";
                strSQL = strSQL + "if @BalCurrentMoney/@OrderPrice>=@PreQTY begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=@PreQTY end ";
                strSQL = strSQL + "else begin ";
                strSQL = strSQL + "set @ReplenisFirstPreQTY=round(@BalCurrentMoney/@OrderPrice,2,1) ";
                strSQL = strSQL + "set @PreQTY=@PreQTY-@ReplenisFirstPreQTY ";
                strSQL = strSQL + "end ";
                strSQL = strSQL + "INSERT INTO KEW_SalesInfoEntry ([FID],[FIndex],[FBillNo_SRC],[FClassID_SRC],[FComboBox1],[FDecimal11],[FDecimal5] ";
                strSQL = strSQL + ",[FDecimal6],[FDecimal7],[FDecimal8],[FDecimal9],[FDecimal10],[FID_SRC],[FEntryID_SRC],[FCheckBox2],[FBase4] ";
                strSQL = strSQL + ",[FText6],[FText7],[FInteger]) VALUES (@FID,1,@OrderNo,@OrderTypeID,'',0,0 ";
                strSQL = strSQL + ",@BalCurrentMoney,@OrderPrice,0,@ReplenisFirstPreQTY,ROUND(@ReplenisFirstPreQTY*@OrderPrice,2),@OrderID,0,0,@GustID,@TakePass" + i.ToString() + ",'',0) ";
                strSQL = strSQL + "if (SELECT COUNT(1) FROM KEW_SalesInfoEntry WHERE FText6=@TakePass" + i.ToString() + " AND FID=@FID)<>1 BEGIN ";
                strSQL = strSQL + "SET @ErrorCount=-1 ";
                strSQL = strSQL + "END ";
                strSQL = strSQL + "SET @ErrorCount=@ErrorCount+@@ERROR ";
            }

            strSQL = strSQL + "IF @ErrorCount=0 AND (SELECT COUNT(1) FROM KEW_SalesInfo WHERE FText5=@Stamp AND FID=@FID)=1 ";
            strSQL = strSQL + "BEGIN ";
            strSQL = strSQL + "SELECT 'TRUE',@FID ";
            strSQL = strSQL + "COMMIT TRAN ";
            strSQL = strSQL + "END ";
            strSQL = strSQL + "ELSE BEGIN ";
            strSQL = strSQL + "SELECT 'FALSE','事务出错回滚' ";
            strSQL = strSQL + "ROLLBACK TRAN ";
            strSQL = strSQL + "END ";
            strSQL = strSQL + "SET NOCOUNT OFF";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            AuthResult authResult = new AuthResult();
            authResult.IsSuccess = rs.Data.Tables[0].Rows[0][0].ToString();
            authResult.AuthFID = rs.Data.Tables[0].Rows[0][1].ToString();

            ht.Add(authResult);
            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //单一车辆详情
    public class A10 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            string strQuery = "";
            string strNewFID = "";
            SalesCarInfor orderInfor = new SalesCarInfor();
            // Dictionary<string, SalesCarInfor> ht = new Dictionary<string, SalesCarInfor>();
            List<SalesCarInfor> ht = new List<SalesCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;

            //,E.FDecimal7 产品单价,E.FDecimal6 剩余金额,E.FDecimal10 扣除金额
            //strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            string strSQL = "select A.FID 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FDecimal 进厂重量,A.FDecimal17 出厂重量,A.FDecimal3 实际净重,A.FDecimal3 出库数量,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FTime1 进厂时间,A.FTime2 出厂时间,A.FText8 磁卡,A.FText12 发货授权编号,B.FName 客户,C.FName 产品,A.FText1 开票人员,A.FText2 进厂司磅,A.FText3 出厂司磅,A.FDecimal19 盈亏,A.FText9 签发人员,D.FName 销售车辆,A.FComboBox3 生产线, A.FCheckBox4 作废标志,E.FDecimal7 产品单价,E.FDecimal6 剩余金额,E.FDecimal10 扣除金额,E.FBillNo_SRC 订单编号 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SalesAccount F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests G on G.FID=F.FID_SRC ";
            strSQL = strSQL + "where A.FID=@FID";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ProductOrder productInfor = new ProductOrder();

                    if (!strNewFID.Equals(dr[0].ToString()))
                    {
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.WeighNumber = dr[1].ToString();
                        orderInfor.CarNumber = dr[2].ToString();
                        orderInfor.PreviousPlan = Math.Round(Common.CDec(dr[3].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.InWeight = Math.Round(Common.CDec(dr[4].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutWeight = Math.Round(Common.CDec(dr[5].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.FactNetWeight = Math.Round(Common.CDec(dr[6].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutStorage = Math.Round(Common.CDec(dr[7].ToString()), Common.QtyPrecision).ToString();

                        strQuery = dr[8].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighStatues = "开票";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighStatues = "已开票";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighStatues = "已进厂计量";
                        }
                        else if (Common.CInt(strQuery) == 3)
                        {
                            orderInfor.WeighStatues = "计量完成";
                        }
                        else if (Common.CInt(strQuery) == -1)
                        {
                            orderInfor.WeighStatues = "已发货授权";
                        }

                        strQuery = dr[24].ToString().Trim();
                        if (Common.CBool(strQuery))
                        {
                            orderInfor.WeighStatues = "已作废";
                        }

                        strQuery = dr[9].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighType = "正常过磅";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighType = "退货";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighType = "空车出厂";
                        }

                        orderInfor.TicketTime = dr[10].ToString();
                        orderInfor.InTime = dr[11].ToString();
                        orderInfor.OutTime = dr[12].ToString();
                        orderInfor.CardNum = dr[13].ToString();
                        orderInfor.OrderNumber = dr[14].ToString();
                        orderInfor.ClientName = dr[15].ToString();
                        orderInfor.ProductName = dr[16].ToString();
                        orderInfor.BillingMan = dr[17].ToString();
                        orderInfor.InSiBang = dr[18].ToString();
                        orderInfor.OutSiBang = dr[19].ToString();
                        orderInfor.ProfitAndLoss = Math.Round(Common.CDec(dr[20].ToString()), Common.PricePrecision).ToString();
                        orderInfor.SignMan = dr[21].ToString();
                        orderInfor.SalesCar = dr[22].ToString();
                        orderInfor.ProduceNumber = dr[23].ToString();
                        strNewFID = orderInfor.FID;
                    }

                    productInfor.Price = Math.Round(Common.CDec(dr[25].ToString()), Common.PricePrecision).ToString();
                    productInfor.SurplusMoney = Math.Round(Common.CDec(dr[26].ToString()), Common.PricePrecision).ToString();
                    productInfor.ConsumeMoney = Math.Round(Common.CDec(dr[27].ToString()), Common.PricePrecision).ToString();
                    productInfor.OrderBillno = dr[28].ToString();
                    orderInfor.listProductOrderInfor.Add(productInfor);
                }
            }

            ht.Add(orderInfor);
            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //单一发货授权详情
    public class A11 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            string strNewFID = "";
            //Dictionary<string, AuthCarInfor> ht = new Dictionary<string, AuthCarInfor>();
            List<AuthCarInfor> ht = new List<AuthCarInfor>();
            List<ProductOrder> listProductOrderInfor = new List<ProductOrder>();

            FunctionParameter fp = new FunctionParameter();
            AuthCarInfor authCar = new AuthCarInfor();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.AuthCarFID;

            string strSQL = "select A.FID 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FText14 发货授权编号,B.FName 客户,C.FName 产品,C.FID 产品FID,C.FCheckBox 是否袋装,E.FDecimal7 产品单价,E.FDecimal6 剩余金额,E.FDecimal10 扣除金额,E.FBillNo_SRC 订单编号 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_ProductsEntry C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SalesAccount F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "where A.FID=@FID and A.FComboBox='-1' and A.FCheckBox4='0' order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ProductOrder productInfor = new ProductOrder();

                    if (!strNewFID.Equals(dr[0].ToString()))
                    {
                        authCar.FID = dr["车辆FID"].ToString();
                        authCar.OrderFID = fp.OrderFID;
                        authCar.WeighNumber = dr["过磅编号"].ToString();
                        authCar.PreviousPlan = Math.Round(Common.CDec(dr["计划预装"].ToString()), Common.QtyPrecision).ToString();
                        authCar.AuthNumber = dr["发货授权编号"].ToString();
                        authCar.CarNumber = dr["车牌号码"].ToString();
                        authCar.ProductName = dr["产品"].ToString();
                        authCar.ProductFID = dr["产品FID"].ToString();
                        authCar.IsBag = dr["是否袋装"].ToString();
                        strNewFID = authCar.FID;
                    }

                    productInfor.Price = Math.Round(Common.CDec(dr["产品单价"].ToString()), Common.PricePrecision).ToString();
                    productInfor.SurplusMoney = Math.Round(Common.CDec(dr["剩余金额"].ToString()), Common.PricePrecision).ToString();
                    productInfor.ConsumeMoney = Math.Round(Common.CDec(dr["扣除金额"].ToString()), Common.PricePrecision).ToString();
                    productInfor.OrderBillno = dr["订单编号"].ToString();
                    listProductOrderInfor.Add(productInfor);
                }
            }

            authCar.listOrderPro = handler.Json.ClassToJson(listProductOrderInfor);
            ht.Add(authCar);
            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //筛选订单信息
    public class A12 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            string strProFID = "";
            //Dictionary<string, MoneyClientOrder> ht = new Dictionary<string, MoneyClientOrder>();
            List<MoneyClientOrder> ht = new List<MoneyClientOrder>();
            List<string> listop = new List<string>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            if (!fp.listOrderFID.Equals("[]") && !fp.listOrderFID.Equals(""))
            {
                listop = (List<string>)handler.Json.JsonToClass(fp.listOrderFID, typeof(List<string>));
            }
            if (!fp.ProductFID.Equals("")) 
            { 
                strProFID = fp.ProductFID;
            }

            SqlParameter[] sps = new SqlParameter[2+listop.Count];
            sps[0] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[0].Value = user.UserName;
            for (int i = 0; i < listop.Count;i++ )
            {
                sps[1 + i] = new SqlParameter("@FID"+i.ToString(), SqlDbType.NChar, 50);
                sps[1 + i].Value = listop[i];
            }
            sps[1 + listop.Count] = new SqlParameter("@ProFID", SqlDbType.NChar, 50);
            sps[1 + listop.Count].Value = strProFID;

            string strSQL = "select A.FID 销售账户FID,A.FBillNo 销售账户编号,D.FName 客户名称,A.FDecimal 付款总计,A.FDecimal1 消费总计,A.FDecimal5 当前余额,A.FDate 下单日期,A.FComboBox 密码方式,E.FName 结算方式,A.FBillNo_SRC 档案编号 from KEW_SalesAccount A ";
            strSQL = strSQL + "left join KEW_SalesGuests B on B.FID=A.FID_SRC ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_SalesAccountEntry F on F.FID=A.FID where ";

            for (int i = 0; i < listop.Count;i++ )
            {
                strSQL = strSQL + "A.FID<>@FID"+i.ToString()+" and ";
            }
            if(!strProFID.Equals(""))
            {
                strSQL = strSQL + " F.FBase2 = @ProFID and ";
            }
            strSQL = strSQL + "B.FBillNo=@FBillNo order by A.FDecimal2 asc";


            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        MoneyClientOrder orderInfor = new MoneyClientOrder();

                        orderInfor.FID = dr[0].ToString();
                        orderInfor.FBillNo = dr[1].ToString();
                        orderInfor.ClientName = dr[2].ToString();
                        orderInfor.PaymentTotal = Math.Round(Common.CDec(dr[3].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.ConsumeTotal = Math.Round(Common.CDec(dr[4].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.CurrentBalance = Math.Round(Common.CDec(dr[5].ToString()), Common.AmountPrecision).ToString();
                        orderInfor.BuildTime = dr[6].ToString();
                        if (dr[7].ToString().Equals("0"))
                        {
                            orderInfor.PassWordWay = "无密码";
                        }
                        else if (dr[7].ToString().Equals("1"))
                        {
                            orderInfor.PassWordWay = "固态密码";
                        }
                        else if (dr[7].ToString().Equals("2"))
                        {
                            orderInfor.PassWordWay = "动态密码";
                        }

                        orderInfor.CaculateWay = dr[8].ToString();
                        orderInfor.GuestFBillNo = dr[9].ToString();
                        orderInfor.TotalPages = nTotalPages;

                        ht.Add(orderInfor);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //信息查询
    public class A13 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            string strQuery = "";
            // Dictionary<string, SalesCarInfor> ht = new Dictionary<string, SalesCarInfor>();
            List<SalesCarInfor> ht = new List<SalesCarInfor>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[6];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;
            sps[1] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[1].Value = user.UserName;
            sps[2] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.StartTime;
            sps[3] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[3].Value = fp.EndTime;
            sps[4] = new SqlParameter("@Statues", SqlDbType.NChar, 50);
            sps[4].Value = fp.Statues;
            sps[5] = new SqlParameter("@CarNum", SqlDbType.NChar, 50);
            sps[5].Value = fp.CarNum;

            string strSQL = "select distinct(A.FID) 车辆FID,A.FBillNo 过磅编号,A.FText 车牌号码,A.FDecimal4 计划预装,A.FDecimal 进厂重量,A.FDecimal1 出厂重量,A.FDecimal2 实际净重,A.FDecimal3 出库数量,A.FComboBox 称量状态,A.FComboBox2 过磅类型,A.FTime 开票时间,A.FTime1 进厂时间,A.FTime2 出厂时间,A.FText8 磁卡,A.FText12 发货授权编号,B.FName 客户,C.FName 产品,A.FText1 开票人员,A.FText2 进厂司磅,A.FText3 出厂司磅,A.FDecimal19 盈亏,A.FText9 签发人员,D.FName 销售车辆,A.FComboBox3 生产线, A.FCheckBox4 作废标志 from KEW_SalesInfo A ";
            strSQL = strSQL + "left join t_Organization B on B.FItemID=A.FBase1 ";
            strSQL = strSQL + "left join KEW_Products C on C.FID=A.FBase ";
            strSQL = strSQL + "left join KEW_SalesCar D on D.FID=A.FBase3 ";
            strSQL = strSQL + "left join KEW_SalesInfoEntry E on E.FID=A.FID ";
            strSQL = strSQL + "left join KEW_SalesAccount F on F.FID=E.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests G on G.FID=F.FID_SRC ";
            strSQL = strSQL + "where (F.FID=@FID or @FID='') and G.FBillNo=@FBillNo and (A.FComboBox=@Statues or @Statues='') and (A.FText like '%'+@BillNo+'%' or @BillNo='') and (A.FTime2>=@StartTime or @StartTime='') and (A.FTime2<=@EndTime or @EndTime='') order by A.FID desc";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        SalesCarInfor orderInfor = new SalesCarInfor();
                        orderInfor.FID = dr[0].ToString();
                        orderInfor.WeighNumber = dr[1].ToString();
                        orderInfor.CarNumber = dr[2].ToString();
                        orderInfor.PreviousPlan = Math.Round(Common.CDec(dr[3].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.InWeight = Math.Round(Common.CDec(dr[4].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutWeight = Math.Round(Common.CDec(dr[5].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.FactNetWeight = Math.Round(Common.CDec(dr[6].ToString()), Common.QtyPrecision).ToString();
                        orderInfor.OutStorage = Math.Round(Common.CDec(dr[7].ToString()), Common.QtyPrecision).ToString();

                        strQuery = dr[8].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighStatues = "开票";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighStatues = "已开票";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighStatues = "已进厂计量";
                        }
                        else if (Common.CInt(strQuery) == 3)
                        {
                            orderInfor.WeighStatues = "计量完成";
                        }
                        else if (Common.CInt(strQuery) == -1)
                        {
                            orderInfor.WeighStatues = "已发货授权";
                        }

                        strQuery = dr[24].ToString().Trim();
                        if (Common.CBool(strQuery))
                        {
                            orderInfor.WeighStatues = "已作废";
                        }

                        strQuery = dr[9].ToString().Trim();
                        if (Common.CInt(strQuery) == 0)
                        {
                            orderInfor.WeighType = "正常过磅";
                        }
                        else if (Common.CInt(strQuery) == 1)
                        {
                            orderInfor.WeighType = "退货";
                        }
                        else if (Common.CInt(strQuery) == 2)
                        {
                            orderInfor.WeighType = "空车出厂";
                        }

                        orderInfor.TicketTime = dr[10].ToString();
                        orderInfor.InTime = dr[11].ToString();
                        orderInfor.OutTime = dr[12].ToString();
                        orderInfor.CardNum = dr[13].ToString();
                        orderInfor.OrderNumber = dr[14].ToString();
                        orderInfor.ClientName = dr[15].ToString();
                        orderInfor.ProductName = dr[16].ToString();
                        orderInfor.BillingMan = dr[17].ToString();
                        orderInfor.InSiBang = dr[18].ToString();
                        orderInfor.OutSiBang = dr[19].ToString();
                        orderInfor.ProfitAndLoss = Math.Round(Common.CDec(dr[20].ToString()), Common.PricePrecision).ToString();
                        orderInfor.SignMan = dr[21].ToString();
                        orderInfor.SalesCar = dr[22].ToString();
                        orderInfor.ProduceNumber = dr[23].ToString();
                        orderInfor.TotalPages = nTotalPages;
                        ht.Add(orderInfor);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;
                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

    //销售收款查询
    public class A14 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, String parameter)
        {
            string strResult = "";
            int nCount = 1;
            int nTotalPages = 0;
            //Dictionary<string, OrderCollection> ht = new Dictionary<string, MoneyClientOrder>();
            List<OrderCollection> ht = new List<OrderCollection>();

            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[4];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.OrderFID;
            sps[1] = new SqlParameter("@FBillNo", SqlDbType.NChar, 50);
            sps[1].Value = user.UserName;
            sps[2] = new SqlParameter("@StartTime", SqlDbType.NChar, 50);
            sps[2].Value = fp.StartTime;
            sps[3] = new SqlParameter("@EndTime", SqlDbType.NChar, 50);
            sps[3].Value = fp.EndTime;

            string strSQL = "select A.FID 销售收款FID, A.FBillNo 销售收款编号 ,A.FBillNo_SRC 销售账户FBillNo,A.FDate 付款日期, D.FName 付款单位,A.FDecimal 付款金额,E.FName 付款方式 ,A.FCheckBox1 是否生效,A.FNOTE 备注 from KEW_SalesCash A ";
            strSQL = strSQL + "left join KEW_SalesAccount B on B.FID = A.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests C on C.FID=B.FID_SRC ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase1 ";
            strSQL = strSQL + "where (B.FID=@FID or @FID='') and C.FBillNo=@FBillNo and A.FCheckBox1 =1 and (B.FDate>=@StartTime or @StartTime= '') and (B.FDate<=@EndTime or @EndTime= '') order by A.FID DESC";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            if (rs.Data.Tables[0].Rows.Count % fp.PageSize == 0)
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize;
            }
            else
            {
                nTotalPages = rs.Data.Tables[0].Rows.Count / fp.PageSize + 1;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if ((fp.PageSize * fp.Page >= nCount) && ((fp.Page - 1) * fp.PageSize < nCount))
                    {
                        OrderCollection orderColl = new OrderCollection();

                        orderColl.FID = dr[0].ToString();
                        orderColl.FBillNo = dr[1].ToString();
                        orderColl.FBillNo_SRC = dr[2].ToString();
                        orderColl.BuildTime = dr[3].ToString();
                        orderColl.PayCompany = dr[4].ToString();
                        orderColl.PayAmount = Math.Round(Common.CDec(dr[5].ToString()), Common.AmountPrecision).ToString();
                        orderColl.PayMode = dr[6].ToString();
                        orderColl.IsEffect = dr[7].ToString();
                        orderColl.Remark = dr[8].ToString();
                        orderColl.TotalPages = nTotalPages;

                        ht.Add(orderColl);
                    }

                    if (nCount == fp.PageSize * fp.Page)
                    {
                        break;

                    }
                    nCount++;
                }
            }

            strResult = handler.Json.ClassToJson(ht);
            return strResult;
        }
    }

    //单一收款详情
    public class A15 : IMobileChild
    {
        public string Code(IMobile handler, ClientUser user, string parameter)
        {
            string strResult = "";
            string strNewFID = "";
            OrderCollection orderColl = new OrderCollection();
            List<OrderCollection> ht = new List<OrderCollection>();
            FunctionParameter fp = new FunctionParameter();

            fp = (FunctionParameter)handler.Json.JsonToClass(parameter, typeof(FunctionParameter));

            SqlParameter[] sps = new SqlParameter[1];
            sps[0] = new SqlParameter("@FID", SqlDbType.NChar, 50);
            sps[0].Value = fp.CashFID;

            string strSQL = "select A.FID 销售收款FID, A.FBillNo 销售收款编号 ,A.FBillNo_SRC 销售账户FBillNo,A.FDate 付款日期, D.FName 付款单位,A.FDecimal 付款金额,E.FName 付款方式 ,A.FCheckBox1 是否生效,A.FNOTE 备注 from KEW_SalesCash A ";
            strSQL = strSQL + "left join KEW_SalesAccount B on B.FID = A.FID_SRC ";
            strSQL = strSQL + "left join KEW_SalesGuests C on C.FID=B.FID_SRC ";
            strSQL = strSQL + "left join t_Organization D on D.FItemID=A.FBase ";
            strSQL = strSQL + "left join t_Settle E on E.FItemID=A.FBase1 ";
            strSQL = strSQL + "where A.FID=@FID";

            Recordset rs = handler.Data.ExeProcedure(user.AccountID, strSQL, sps);

            if (rs == null || rs.Data.Tables.Count <= 0 || rs.Data.Tables[0].Rows.Count <= 0)
            {
                strResult = "";
                return strResult;
            }

            foreach (DataTable dt in rs.Data.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ProductOrder productInfor = new ProductOrder();

                    if (!strNewFID.Equals(dr[0].ToString()))
                    {
                        orderColl.FID = dr[0].ToString();
                        orderColl.FBillNo = dr[1].ToString();
                        orderColl.FBillNo_SRC = dr[2].ToString();
                        orderColl.BuildTime = dr[3].ToString();
                        orderColl.PayCompany = dr[4].ToString();
                        orderColl.PayAmount = Math.Round(Common.CDec(dr[5].ToString()), Common.AmountPrecision).ToString();
                        orderColl.PayMode = dr[6].ToString();
                        orderColl.IsEffect = dr[7].ToString();
                        orderColl.Remark = dr[8].ToString();
                        strNewFID = orderColl.FID;
                        
                    }


                }
            }

            ht.Add(orderColl);
            strResult = handler.Json.ClassToJson(ht);

            return strResult;
        }
    }

}
